<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-table
          ref="table"
          :columns="columns"
          :dataSource="list"
          :pagination="ipagination"
          :loading="loading"
          size="middle"
          @change="handleTableChange"
        >
          <!-- 字符串超长截取省略号显示-->
          <span slot="personalAdvantage" slot-scope="text, record">
            <j-ellipsis :value="text" :length="10" />
          </span>
        </a-table>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import pick from 'lodash.pick'
import moment from 'moment'
import JEllipsis from '@/components/jeecg/JEllipsis'
import JSuperQuery from '@/components/jeecg/JSuperQuery.vue'

export default {
  name: 'TestModal',
  components: {
    JEllipsis,
    JSuperQuery
  },
  data() {
    return {
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },

      list: [],

      title: '操作',
      visible: false,
      selectedDepUsers: '',
      model: {},

      columns: [
        {
          title: '用户ID',
          align: 'center',
          dataIndex: 'userId'
        },
        {
          title: '记录时间',
          align: 'center',
          dataIndex: 'markerTime'
        },
        {
          title: '获取方式',
          align: 'center',
          dataIndex: 'getOrUser_dictText'
        },
        {
          title: '涉及到的积分数量',
          align: 'center',
          dataIndex: 'integralNum'
        }
      ],

      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },

      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {},
      url: {
        list: "/integralLogs/integralLogs/list"
      }
    }
  },
  created() {},
  methods: {
    handleTableChange(pagination, filters, sorter) {
      this.ipagination = pagination
      this.getList(this.id)
      this.loadData();
    },
    getList(id) {
      this.teacherId = id
      this.form.resetFields()
      this.visible = true
      getAction(this.url.list, { userId: id, pageNo: this.ipagination.current, pageSize: this.ipagination.pageSize }).then(
        res => {
          if (res.success) {
            this.list = res.result.records

            this.ipagination.total = res.result.total
            this.ipagination.current = res.result.current

            this.ipagination.pages = res.result.pages
            this.ipagination.size = res.result.size
          }
        }
      )
    },
    loadData(){
        
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.close()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style lang="less" scoped>
</style>